/**********************************************************
 * InitializeJobs.java.java 
 * Created by Ashutosh
 * Last modified Date: Sep 18, 2008 11:04:07 AM by Ashutosh
 * Revision: <svn revision #> 
 * Version : 0.1
 * Copyright (c) 2008 - 2009 cyberThink Infotech Pvt. Ltd., All rights reserved.
 **********************************************************/

package com.printeverywhere.servlet;

import org.apache.log4j.Logger;
import java.util.Date;
import javax.servlet.http.HttpServlet;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SimpleTrigger;
import org.quartz.impl.StdSchedulerFactory;
import com.printeverywhere.job.JTest;

/**
 * The Class InitializeJobs.
 */
public class InitializeJobs extends HttpServlet {
	
	/** Logger for this class. */
	private static final Logger logger = Logger.getLogger(InitializeJobs.class);

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 1L;

	/* (non-Javadoc)
	 * @see javax.servlet.GenericServlet#init()
	 */
	public void init() {
		if (logger.isDebugEnabled()) {
			logger.debug("init() - start"); //$NON-NLS-1$
		}

		try {
			 //ActionProxy proxy = .createActionProxy("", context.getJobDetail().getName(), ctx);
			 Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler ();
			 JobDetail jobDetail = new JobDetail ( "test", Scheduler.DEFAULT_GROUP, JTest.class);
			 long ctime = System.currentTimeMillis ();
			 SimpleTrigger simpleTrigger = new SimpleTrigger ( " simpleTrigger "," triggerGroup-s1 ");
			 simpleTrigger.setStartTime (new Date (ctime));
			 simpleTrigger.setRepeatInterval(2000);
			 simpleTrigger.setRepeatCount(100);
			 scheduler.scheduleJob(jobDetail, simpleTrigger);
			 scheduler.start ();
		 } catch (Exception e) {
			logger.error("init()", e); //$NON-NLS-1$

			 e.printStackTrace();
		 }

		if (logger.isDebugEnabled()) {
			logger.debug("init() - end"); //$NON-NLS-1$
		}
	}
}